package com.lovo.J177.controller;


import com.lovo.J177.model.dto.SStudentDTO;
import com.lovo.J177.result.ResponseResult;
import com.lovo.J177.service.SStudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author bdk
 * @since 2020-11-24
 */
@Api("学生信息的控制器")
@RestController
@RequestMapping("/stdents")
@ResponseResult
public class SStudentController {
    @Resource
    private SStudentService studentService;

    @ApiOperation("查询所有学生")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页" ,example = "1"),
            @ApiImplicitParam(name = "size", value = "每页显示数" ,example = "5")
    })
    @GetMapping("/findAll")

    public Object showAll( Integer page, Integer size)
    {
//        System.out.println(studentService);
        return studentService.selectPageExt(page,size);
    }

    @PostMapping

    public Object save(@RequestBody @Valid SStudentDTO studentDTO){
        studentService.saveStudent(studentDTO);
        return null;
    }
    @GetMapping("/findById")
    public Object findById(String id){
   return studentService.findById(id);
    }
    @PutMapping
    public Object update(@Valid SStudentDTO studentDTO){
        studentService.updateStudent(studentDTO);
        return  null;
    }
    @DeleteMapping("/{id}")
    public Object del(String id){
        studentService.del(id);
        return  null;
    }


}

